<script setup lang="ts">
import { ref } from 'vue'
import { useRouter } from 'vue-router'

const router = useRouter()
const countdown = ref(5)

// 倒计时自动返回首页
const timer = setInterval(() => {
  countdown.value--
  if (countdown.value <= 0) {
    clearInterval(timer)
    router.push('/')
  }
}, 1000)

// 清理定时器
onUnmounted(() => {
  clearInterval(timer)
})
</script>

<template>
  <div class="not-found-container">
    <div class="not-found-content">
      <h1 class="not-found-title">404</h1>
      <p class="not-found-message">页面不存在</p>
      <p class="not-found-description">抱歉，您访问的页面不存在或已被删除。</p>
      <p class="not-found-redirect">
        将于 {{ countdown }} 秒后自动返回首页，或
        <button @click="router.push('/')" class="redirect-button">
          立即返回
        </button>
      </p>
    </div>
  </div>
</template>

<style scoped>
.not-found-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background-color: #f5f5f5;
}

.not-found-content {
  text-align: center;
  padding: 40px;
  background-color: white;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.not-found-title {
  font-size: 100px;
  font-weight: bold;
  color: #333;
  margin-bottom: 20px;
}

.not-found-message {
  font-size: 24px;
  color: #555;
  margin-bottom: 10px;
}

.not-found-description {
  font-size: 16px;
  color: #777;
  margin-bottom: 20px;
}

.not-found-redirect {
  font-size: 14px;
  color: #999;
}

.redirect-button {
  background-color: var(--color-secondary);
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  margin-left: 5px;
  transition: background-color 0.3s;
}

.redirect-button:hover {
  background-color: var(--color-primary);
}
</style>
